class AddDiagnosisIdToPatient < ActiveRecord::Migration
  def self.up
    add_column :patients, :diagnosis_id, :integer, :null => false
    
    diagnosis = Diagnosis.find(:first)
    Patient.find(:all).each do |patient|
      patient.diagnosis = diagnosis
      patient.save
    end
    add_index :patients, :diagnosis_id
  end

  def self.down
    remove_index :patients, :diagnosis_id
    remove_column :patients, :diagnosis_id
  end
end
